package 马走日;

import java.util.Scanner;

public class Main {
    static int N = 10, n, m, ans;
    static boolean[][] st = new boolean[N][N];
    static int[] dx = {-2, -1, 1, 2, 2, 1, -1, -2};
    static int[] dy = {1, 2, 2, 1, -1, -2, -2, -1};

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        while (T-- > 0) {
            ans = 0;
            n = in.nextInt();
            m = in.nextInt();
            int x = in.nextInt();
            int y = in.nextInt();
            dfs(x, y, 1);
            System.out.println(ans);
        }
    }

    private static void dfs(int x, int y, int cnt) {
        if (cnt == n * m) {
            ans++;
            return;
        }
        st[x][y] = true;
        for (int i = 0; i < 8; i++) {
            int a = dx[i] + x;
            int b = dy[i] + y;
            if (a < 0 || a >= n || b < 0 || b >= m) {
                continue;
            }
            if (st[a][b]) {
                continue;
            }
            dfs(a, b, cnt + 1);
        }
        st[x][y] = false;
    }
}
